<?php
//从php5.6+

function add($a, ...$args)
{

    $result = 0;
    foreach ($args as $s) {
        $result += $s;

    }
    return $result;
}
$a = 1;
$b = 2;
$sum = add($a, $b);
var_dump($sum);

$c = 3;
$sum = add($a, $b, $c);
var_dump($sum);
